﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Taobao.Public;

namespace Taobao.Filter
{
    public class ExceptionFilterAttribute : HandleErrorAttribute
    {
        public override void OnException(ExceptionContext filterContext)
        {
            HttpResponseBase resp = filterContext.RequestContext.HttpContext.Response;
            Exception ex = filterContext.Exception;
            string msg = ex.Message;
            string url = HttpContext.Current.Request.RawUrl;//发生错误地址
            //记录错误日志 
            Constant.ErrorQueue.Enqueue(msg + "," + url);
            //  HttpContext.Current.Response.Write("<script>window.parent.location.href='/Error/Index'</script>");
            filterContext.ExceptionHandled = true;
            //  filterContext.Result = new ViewResult { ViewName = "Error" };
            //导向友好错误界面
            filterContext.Result = new RedirectResult("/Error/Index");

            //base.OnException(filterContext);
        }
    }
}